<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>文件处理</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
</head>
<body>
    <div class="container py-5">
        <div class="row">
            <div class="col-md-8 offset-md-2">
                <div class="card">
                    <div class="card-header bg-warning text-white">
                        <h4 class="mb-0">文件处理</h4>
                    </div>
                    <div class="card-body">
                        <div class="row mb-4">
                            <div class="col-md-12">
                                <h5>文件信息</h5>
                                <p><strong>文件名：</strong> <span th:text="${file.originalFileName}"></span></p>
                                <p><strong>文件类型：</strong> <span th:text="${file.fileType}"></span></p>
                                <p><strong>文件大小：</strong> <span th:text="${#numbers.formatDecimal(file.fileSize / 1024, 0, 2) + ' KB'}"></span></p>
                                <p><strong>上传时间：</strong> <span th:text="${#dates.format(file.uploadTime, 'yyyy-MM-dd HH:mm')}"></span></p>
                            </div>
                        </div>

                        <h5 class="mb-3">选择操作</h5>
                        <form th:action="@{/process/{id}(id=${file.id})}" method="post">
                            <div class="mb-3">
                                <label for="operation" class="form-label">操作类型</label>
                                <select class="form-select" id="operation" name="operation" required>
                                    <option value="" selected disabled>请选择操作</option>
                                    <option value="rename">重命名</option>
                                    <option value="compress">压缩</option>
                                    <option value="copy">复制</option>
                                </select>
                            </div>
                            
                            <div class="mb-3" id="renameParams">
                                <label for="param" class="form-label">新文件名</label>
                                <input type="text" class="form-control" id="param" name="param" placeholder="输入新文件名（不含扩展名）">
                            </div>
                            
                            <div class="d-flex justify-content-between">
                                <a th:href="@{/}" class="btn btn-secondary">返回</a>
                                <button type="submit" class="btn btn-warning">处理</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            const operation = document.getElementById('operation');
            const renameParams = document.getElementById('renameParams');
            
            function updateParamVisibility() {
                if (operation.value === 'rename') {
                    renameParams.style.display = 'block';
                } else {
                    renameParams.style.display = 'none';
                }
            }
            
            operation.addEventListener('change', updateParamVisibility);
            updateParamVisibility(); // 初始状态设置
        });
    </script>
</body>
</html> 